/*
 * BarajaFrancesa.java
 *
 * Created on 17 de junio de 2007, 11:15
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package poker;

import java.util.Iterator;
import java.util.LinkedList;


/**
 *
 * @author jose
 */
public class BarajaFrancesa {
   public static String[] listaCartasSpanish = {"As de Corazones","2 de Corazones","3 de Corazones","4 de Corazones",
        "5 de Corazones","6 de Corazones","7 de Corazones","8 de Corazones","9 de Corazones",
        "10 de Corazones","Jota de Corazones","Reina de Corazones","Rey de Corazones",
        "As de Rombos","2 de Rombos","3 de Rombos","4 de Rombos",
        "5 de Rombos","6 de Rombos","7 de Rombos","8 de Rombos","9 de Rombos",
        "10 de Rombos","Jota de Rombos","Reina de Rombos","Rey de Rombos",
        "As de Treboles","2 de Treboles","3 de Treboles","4 de Treboles",
        "5 de Treboles","6 de Treboles","7 de Treboles","8 de Treboles","9 de Treboles",
        "10 de Treboles","Jota de Treboles","Reina de Treboles","Rey de Treboles",
        "As de Picas","2 de Picas","3 de Picas","4 de Picas",
        "5 de Picas","6 de Picas","7 de Picas","8 de Picas","9 de Picas",
        "10 de Picas","Jota de Picas","Reina de Picas","Rey de Picas","Aleatorio"};  
    public static String[] listaCartasIngles = {"Ace of hearts","2 of hearts","3 of hearts","4 of hearts",
        "5 of hearts","6 of hearts","7 of hearts","8 of hearts","9 of hearts",
        "10 of hearts","Jack of hearts","Queen of hearts","King of hearts",
        "Ace of diamonds","2 of diamonds","3 of diamonds","4 of diamonds",
        "5 of diamonds","6 of diamonds","7 of diamonds","8 of diamonds","9 of diamonds",
        "10 of diamonds","Jack of diamonds","Queen of diamonds","King of diamonds",
        "Ace of club","2 of club","3 of club","4 of club",
        "5 of club","6 of club","7 of club","8 of club","9 of club",
        "10 of club","Jack of club","Queen of club","King of club",
        "Ace of spade","2 of spade","3 of spade","4 of spade",
        "5 of spade","6 of spade","7 of spade","8 of spade","9 of spade",
        "10 of spade","Jack of spade","Queen of spade","Queen  of spade","Random"};  
    LinkedList baraja = new LinkedList();
    /**
     * Creates a new instance of BarajaFrancesa
     */
    public BarajaFrancesa() {
        for (int i =  1; i <= 4; i++){
           for (int j =  2; j <= 14; j++){
                Carta c = new Carta(i,j);
                baraja.add(c);
                
            }
        }
    }
    
    public void restaurarBaraja(){
        baraja.clear();
        for (int i =  1; i <= 4; i++){
           for (int j =  2; j <= 14; j++){
                Carta c = new Carta(i,j);
                baraja.add(c);
                
            }
        }
    }
    
    public String[] mostrarBaraja(){
       String l[] = null;
         for (int i =  1; i < baraja.size(); i++){
                l[i] = baraja.get(i).toString();
                
        }
        
        return l;
    }
    
    public Carta sacarCarta(){
        return (Carta)baraja.remove(Aleatorio.random(0,baraja.size()-1));
    }
    
    public Carta sacarCarta(int valor,int palo) 
    {
     
        Iterator it = baraja.iterator();
        while (it.hasNext())
        {
            Carta c =(Carta) it.next();
            if ((c.palo == palo) && (c.valor == valor))
            {
                it.remove();
                return c;
            }
        }
        return new Carta(0,0);
    }
    
    public boolean existe(int valor, int palo)
    {
            Iterator it = baraja.iterator();
            while (it.hasNext())
            {
                Carta c =(Carta) it.next();
                if ((c.palo == palo) && (c.valor == valor))
                {
                    return true;
                }
            }
        return false;    
    }
    
    public static int DevolverPalo(String cadena){
        if ((cadena.contains("Corazones"))||(cadena.contains("hearts"))){
            return 1;
        }
        if ((cadena.contains("Rombos"))||(cadena.contains("diamonds"))){
            return 2;
        }
        if ((cadena.contains("Treboles"))||(cadena.contains("club"))){
            return 3;
        }
        if ((cadena.contains("Picas"))||(cadena.contains("spade"))){
            return 4;
        }           
        
        return 0;
    }
    
    public static int DevolverValor(String cadena){
        if ((cadena.contains("As "))||(cadena.contains("Ace "))){
            return 14;
        }
        if (cadena.contains("2")){
            return 2;
        }
        if (cadena.contains("3")){
            return 3;
        }
        if (cadena.contains("4")){
            return 4;
        }           
        if (cadena.contains("5")){
            return 5;
        }
        if (cadena.contains("6")){
            return 6;
        }
        if (cadena.contains("7")){
            return 7;
        }
        if (cadena.contains("8")){
            return 8;
        }
        if (cadena.contains("9 ")){
            return 9;
        }
        if (cadena.contains("10 ")){
            return 10;
        }
        if ((cadena.contains("Jota"))||(cadena.contains("Jack"))){
            return 11;
        }
        if ((cadena.contains("Reina"))||(cadena.contains("Queen"))){
            return 12;
        }
        
        if ((cadena.contains("Rey"))||(cadena.contains("King"))){
            return 13;
        }  
        return 0;
    }
    
    
    
}
